﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Users_MyOrder : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IDCard != null)
        {
            if (!Page.IsPostBack)
            {
                bindDTable();
            }
        }
    }
    private void bindDTable()
    {
        DataTable dt = Exam.getOrderInfosByIdCard(IDCard);
        if (dt.Columns.Contains("OrderStateCHN"))
            dt.Columns.Remove("OrderStateCHN");
        dt.Columns.Add("OrderStateCHN");
        foreach (DataRow dr in dt.Rows)
        {
            if (dr["OrderState"].ToString().Trim() == "0")
            {
                dr["OrderStateCHN"] = "未缴费";
            }
            else if (dr["OrderState"].ToString().Trim() == "5")
            {
                dr["OrderStateCHN"] = "缴费中";
            }
            else
            {
                dr["OrderStateCHN"] = "已缴费";
            }
        }

        gv.DataSource = dt;
        gv.DataBind();
    }

    protected void nextGoPay_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            HyperLink hlNextGoPay = (HyperLink)e.Row.FindControl("nextGoPay");
            string orderState = gv.DataKeys[e.Row.RowIndex].Values[1].ToString().Trim();
            string orderId = gv.DataKeys[e.Row.RowIndex].Values[0].ToString().Trim();
            DataTable dt = Exam.getOrderInfoByOrderID(orderId);
            if (dt.Rows.Count > 0)
            {
                string emId = dt.Rows[0]["EmID"].ToString();
                
            }
            if (orderState == "0")
            {
                hlNextGoPay.NavigateUrl = BSUtility.mainUrl + "BM/BM4.aspx?OrderID=" + orderId;
            }
            else if(orderState == "5")
            {

                hlNextGoPay.NavigateUrl = BSUtility.mainUrl + "BM/BM4.aspx?OrderID=" + orderId;
            }
            else if(orderState == "9")
            {
                hlNextGoPay.Visible = false;
            }
            
        }
    }
}